FROM maven:3-jdk-8-alpine
WORKDIR /app
COPY pom.xml .
RUN mvn -Dmaven.test.skip=true package

FROM maven:3-jdk-8-alpine
WORKDIR /app
COPY src ./src
COPY --from=0 /app/pom.xml ./pom.xml
COPY --from=0 /root/.m2 /root/.m2
RUN mvn -Dmaven.test.skip=true package

FROM registry.cn-beijing.aliyuncs.com/codeforfun/openjdk:8-jre-alpine
WORKDIR /app
COPY --from=1 /app/target/app.jar ./app.jar
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=docker","/app/app.jar"]

